/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using System.Collections.Generic;
using NetProtocol.POD;
using NetProtocol.Enum;
using IQIGame.Onigao.Game;
using IQIGame.Onigao.GamePlay;
using IQIGame.Onigao.Framework;
using Cysharp.Threading.Tasks;
using System;
using static IQIGame.Onigao.Game.MessageWrapper;

namespace NetProtocol.Client {
	/// <summary>
	/// 宠物模块
	/// module : pet
	/// </summary>
	public interface CNetPet : INetClientModule {
		
		public ISession GetSession();
	
		Dictionary<int, INetClientModule.Package2MessageWrapper> INetClientModule.GetModuleFunction()
        {
            MessageFunction freeResult_Delegate = (session, wrapper) =>
            {
            	var _wrapper = (MessageWrapper<FreeResultData>)wrapper;
                SC_freeResult(session, ref _wrapper.message);
                MessageWrapperPool<FreeResultData>.Put(_wrapper);
            };
            MessageFunction upLevelResult_Delegate = (session, wrapper) =>
            {
            	var _wrapper = (MessageWrapper<UpLevelResultData>)wrapper;
                SC_upLevelResult(session, ref _wrapper.message);
                MessageWrapperPool<UpLevelResultData>.Put(_wrapper);
            };
            MessageFunction renameResult_Delegate = (session, wrapper) =>
            {
            	var _wrapper = (MessageWrapper<RenameResultData>)wrapper;
                SC_renameResult(session, ref _wrapper.message);
                MessageWrapperPool<RenameResultData>.Put(_wrapper);
            };
            MessageFunction lockResult_Delegate = (session, wrapper) =>
            {
            	var _wrapper = (MessageWrapper<LockResultData>)wrapper;
                SC_lockResult(session, ref _wrapper.message);
                MessageWrapperPool<LockResultData>.Put(_wrapper);
            };
            MessageFunction unlockSkillSlotResult_Delegate = (session, wrapper) =>
            {
            	var _wrapper = (MessageWrapper<UnlockSkillSlotResultData>)wrapper;
                SC_unlockSkillSlotResult(session, ref _wrapper.message);
                MessageWrapperPool<UnlockSkillSlotResultData>.Put(_wrapper);
            };
            MessageFunction putOnRandAttrResult_Delegate = (session, wrapper) =>
            {
            	var _wrapper = (MessageWrapper<PutOnRandAttrResultData>)wrapper;
                SC_putOnRandAttrResult(session, ref _wrapper.message);
                MessageWrapperPool<PutOnRandAttrResultData>.Put(_wrapper);
            };
            MessageFunction putOffRandAttrResult_Delegate = (session, wrapper) =>
            {
            	var _wrapper = (MessageWrapper<PutOffRandAttrResultData>)wrapper;
                SC_putOffRandAttrResult(session, ref _wrapper.message);
                MessageWrapperPool<PutOffRandAttrResultData>.Put(_wrapper);
            };
            MessageFunction notifyPetActive_Delegate = (session, wrapper) =>
            {
            var _wrapper = (MessageWrapper<NotifyPetActiveData>)wrapper; 
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.pet_notifyPetActive, "Recv->" + _wrapper.message.ToString());
#endif
                SC_notifyPetActive(session, _wrapper.message.petPOD);
                MessageWrapperPool<NotifyPetActiveData>.Put(_wrapper);
            };
            MessageFunction notifyPetBagCapacity_Delegate = (session, wrapper) =>
            {
            var _wrapper = (MessageWrapper<NotifyPetBagCapacityData>)wrapper; 
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.pet_notifyPetBagCapacity, "Recv->" + _wrapper.message.ToString());
#endif
                SC_notifyPetBagCapacity(session, _wrapper.message.capacity);
                MessageWrapperPool<NotifyPetBagCapacityData>.Put(_wrapper);
            };
            MessageFunction notifyPetRemove_Delegate = (session, wrapper) =>
            {
            var _wrapper = (MessageWrapper<NotifyPetRemoveData>)wrapper; 
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.pet_notifyPetRemove, "Recv->" + _wrapper.message.ToString());
#endif
                SC_notifyPetRemove(session, _wrapper.message.removeList);
                MessageWrapperPool<NotifyPetRemoveData>.Put(_wrapper);
            };
        
            Dictionary<int, INetClientModule.Package2MessageWrapper> retDic = new()
            {
                {NetMessageId.pet_freeResult, (session, package) => {
                	var result = MessageWrapperPool<FreeResultData>.Get();
                	result.Init(session, freeResult_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.pet_upLevelResult, (session, package) => {
                	var result = MessageWrapperPool<UpLevelResultData>.Get();
                	result.Init(session, upLevelResult_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.pet_renameResult, (session, package) => {
                	var result = MessageWrapperPool<RenameResultData>.Get();
                	result.Init(session, renameResult_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.pet_lockResult, (session, package) => {
                	var result = MessageWrapperPool<LockResultData>.Get();
                	result.Init(session, lockResult_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.pet_unlockSkillSlotResult, (session, package) => {
                	var result = MessageWrapperPool<UnlockSkillSlotResultData>.Get();
                	result.Init(session, unlockSkillSlotResult_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.pet_putOnRandAttrResult, (session, package) => {
                	var result = MessageWrapperPool<PutOnRandAttrResultData>.Get();
                	result.Init(session, putOnRandAttrResult_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.pet_putOffRandAttrResult, (session, package) => {
                	var result = MessageWrapperPool<PutOffRandAttrResultData>.Get();
                	result.Init(session, putOffRandAttrResult_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.pet_notifyPetActive, (session, package) => {
                	var result = MessageWrapperPool<NotifyPetActiveData>.Get();
                	result.Init(session, notifyPetActive_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.pet_notifyPetBagCapacity, (session, package) => {
                	var result = MessageWrapperPool<NotifyPetBagCapacityData>.Get();
                	result.Init(session, notifyPetBagCapacity_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.pet_notifyPetRemove, (session, package) => {
                	var result = MessageWrapperPool<NotifyPetRemoveData>.Get();
                	result.Init(session, notifyPetRemove_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
            };
            return retDic;
        }
#region Client-side Interface
		/// <summary>
        ///  放生结果，从本地移除			
        /// </summary>
		public void SC_freeResult(ISession session, ref FreeResultData message) 
		{
            _SC_freeResult(session, ref message);
		}
		
		public void _SC_freeResult(ISession session, ref FreeResultData message)
		{
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.pet_freeResult, "Recv->" + message.ToString());
#endif
			NetProtocolHelper.endCallRequest?.Invoke(NetMessageId.pet_freeResult, message.code);
			MsgAsyncAwaiter<FreeResultData>.Instance.CompleteMsgAwait(ref message);
		}
		
		/// <summary>
        ///  升级结果，成功时替换
        /// </summary>
		public void SC_upLevelResult(ISession session, ref UpLevelResultData message) 
		{
            _SC_upLevelResult(session, ref message);
		}
		
		public void _SC_upLevelResult(ISession session, ref UpLevelResultData message)
		{
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.pet_upLevelResult, "Recv->" + message.ToString());
#endif
			NetProtocolHelper.endCallRequest?.Invoke(NetMessageId.pet_upLevelResult, message.code);
			MsgAsyncAwaiter<UpLevelResultData>.Instance.CompleteMsgAwait(ref message);
		}
		
		/// <summary>
        ///  重命名结果，自行替换名字
        /// </summary>
		public void SC_renameResult(ISession session, ref RenameResultData message) 
		{
            _SC_renameResult(session, ref message);
		}
		
		public void _SC_renameResult(ISession session, ref RenameResultData message)
		{
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.pet_renameResult, "Recv->" + message.ToString());
#endif
			NetProtocolHelper.endCallRequest?.Invoke(NetMessageId.pet_renameResult, message.code);
			MsgAsyncAwaiter<RenameResultData>.Instance.CompleteMsgAwait(ref message);
		}
		
		/// <summary>
        ///  锁定结果
        /// </summary>
		public void SC_lockResult(ISession session, ref LockResultData message) 
		{
            _SC_lockResult(session, ref message);
		}
		
		public void _SC_lockResult(ISession session, ref LockResultData message)
		{
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.pet_lockResult, "Recv->" + message.ToString());
#endif
			NetProtocolHelper.endCallRequest?.Invoke(NetMessageId.pet_lockResult, message.code);
			MsgAsyncAwaiter<LockResultData>.Instance.CompleteMsgAwait(ref message);
		}
		
		/// <summary>
        ///  解锁技能槽
        /// </summary>
		public void SC_unlockSkillSlotResult(ISession session, ref UnlockSkillSlotResultData message) 
		{
            _SC_unlockSkillSlotResult(session, ref message);
		}
		
		public void _SC_unlockSkillSlotResult(ISession session, ref UnlockSkillSlotResultData message)
		{
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.pet_unlockSkillSlotResult, "Recv->" + message.ToString());
#endif
			NetProtocolHelper.endCallRequest?.Invoke(NetMessageId.pet_unlockSkillSlotResult, message.code);
			MsgAsyncAwaiter<UnlockSkillSlotResultData>.Instance.CompleteMsgAwait(ref message);
		}
		
		/// <summary>
        ///  使用词条效果
        /// </summary>
		public void SC_putOnRandAttrResult(ISession session, ref PutOnRandAttrResultData message) 
		{
            _SC_putOnRandAttrResult(session, ref message);
		}
		
		public void _SC_putOnRandAttrResult(ISession session, ref PutOnRandAttrResultData message)
		{
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.pet_putOnRandAttrResult, "Recv->" + message.ToString());
#endif
			NetProtocolHelper.endCallRequest?.Invoke(NetMessageId.pet_putOnRandAttrResult, message.code);
			MsgAsyncAwaiter<PutOnRandAttrResultData>.Instance.CompleteMsgAwait(ref message);
		}
		
		/// <summary>
        ///  取下词条效果
        /// </summary>
		public void SC_putOffRandAttrResult(ISession session, ref PutOffRandAttrResultData message) 
		{
            _SC_putOffRandAttrResult(session, ref message);
		}
		
		public void _SC_putOffRandAttrResult(ISession session, ref PutOffRandAttrResultData message)
		{
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.pet_putOffRandAttrResult, "Recv->" + message.ToString());
#endif
			NetProtocolHelper.endCallRequest?.Invoke(NetMessageId.pet_putOffRandAttrResult, message.code);
			MsgAsyncAwaiter<PutOffRandAttrResultData>.Instance.CompleteMsgAwait(ref message);
		}
		
		/// <summary>
        ///  通知激活了宠物
        /// </summary>
		protected void SC_notifyPetActive(ISession session, PetPOD petPOD);
		/// <summary>
        ///  通知宠物背包容量变化
        /// </summary>
		protected void SC_notifyPetBagCapacity(ISession session, int capacity);
		/// <summary>
        ///  通知删除了宠物--主要用于gm
        /// </summary>
		protected void SC_notifyPetRemove(ISession session, List<long> removeList);
#endregion
#region Server-side Interface
		/// <summary>
        ///  放生
        /// </summary>
    	public UniTask<FreeResultData> CS_free(long id)
        {
            return _CS_free(id);
        }
        
        public UniTask<FreeResultData> _CS_free(long id)
        {
        	ISession session = GetSession();
        	if(session == null) return UniTask.FromResult(default(FreeResultData));
#if ENABLE_NET_LOG || UNITY_EDITOR
			NetProtocolHelper.ClientLog(NetMessageId.pet_free, "Send->"+"Pet.CS_free { "
				+ "id="
				+ id
				+" }");
#endif
        	UniTask<FreeResultData> task = MsgAsyncAwaiter<FreeResultData>.Instance.AddMsgAwait();
        	session.SendPack(Pack_for_free(id));
        	NetProtocolHelper.beginCallRequest?.Invoke(NetMessageId.pet_freeResult);
			return task;
        }
		
		public static SendPackage Pack_for_free(long id) 
		{
			SendPackage si_p = NetProtocolHelper.GetSendPackage();
			si_p.Header.Messagid = NetMessageId.pet_free;
			si_p.StartWrite();
			SOutputStream _out = si_p.OutputStream;
			_out.Write_long(id);
			return si_p;
		}
		/// <summary>
        ///  升级 -- 参数为材料数
        /// </summary>
    	public UniTask<UpLevelResultData> CS_upLevel(long id, int itemCount)
        {
            return _CS_upLevel(id, itemCount);
        }
        
        public UniTask<UpLevelResultData> _CS_upLevel(long id, int itemCount)
        {
        	ISession session = GetSession();
        	if(session == null) return UniTask.FromResult(default(UpLevelResultData));
#if ENABLE_NET_LOG || UNITY_EDITOR
			NetProtocolHelper.ClientLog(NetMessageId.pet_upLevel, "Send->"+"Pet.CS_upLevel { "
				+ "id="
				+ id
				+ ", itemCount="
				+ itemCount
				+" }");
#endif
        	UniTask<UpLevelResultData> task = MsgAsyncAwaiter<UpLevelResultData>.Instance.AddMsgAwait();
        	session.SendPack(Pack_for_upLevel(id, itemCount));
        	NetProtocolHelper.beginCallRequest?.Invoke(NetMessageId.pet_upLevelResult);
			return task;
        }
		
		public static SendPackage Pack_for_upLevel(long id, int itemCount) 
		{
			SendPackage si_p = NetProtocolHelper.GetSendPackage();
			si_p.Header.Messagid = NetMessageId.pet_upLevel;
			si_p.StartWrite();
			SOutputStream _out = si_p.OutputStream;
			_out.Write_long(id);
			_out.Write_int(itemCount);
			return si_p;
		}
		/// <summary>
        ///  重命名
        /// </summary>
    	public UniTask<RenameResultData> CS_rename(long id, string newName)
        {
            return _CS_rename(id, newName);
        }
        
        public UniTask<RenameResultData> _CS_rename(long id, string newName)
        {
        	ISession session = GetSession();
        	if(session == null) return UniTask.FromResult(default(RenameResultData));
#if ENABLE_NET_LOG || UNITY_EDITOR
			NetProtocolHelper.ClientLog(NetMessageId.pet_rename, "Send->"+"Pet.CS_rename { "
				+ "id="
				+ id
				+ ", newName="
				+ newName
				+" }");
#endif
        	UniTask<RenameResultData> task = MsgAsyncAwaiter<RenameResultData>.Instance.AddMsgAwait();
        	session.SendPack(Pack_for_rename(id, newName));
        	NetProtocolHelper.beginCallRequest?.Invoke(NetMessageId.pet_renameResult);
			return task;
        }
		
		public static SendPackage Pack_for_rename(long id, string newName) 
		{
			SendPackage si_p = NetProtocolHelper.GetSendPackage();
			si_p.Header.Messagid = NetMessageId.pet_rename;
			si_p.StartWrite();
			SOutputStream _out = si_p.OutputStream;
			_out.Write_long(id);
			_out.Write_string(newName);
			return si_p;
		}
		/// <summary>
        ///  锁定
        /// </summary>
    	public UniTask<LockResultData> CS_lock(long id, bool isLock)
        {
            return _CS_lock(id, isLock);
        }
        
        public UniTask<LockResultData> _CS_lock(long id, bool isLock)
        {
        	ISession session = GetSession();
        	if(session == null) return UniTask.FromResult(default(LockResultData));
#if ENABLE_NET_LOG || UNITY_EDITOR
			NetProtocolHelper.ClientLog(NetMessageId.pet_lock, "Send->"+"Pet.CS_lock { "
				+ "id="
				+ id
				+ ", isLock="
				+ isLock
				+" }");
#endif
        	UniTask<LockResultData> task = MsgAsyncAwaiter<LockResultData>.Instance.AddMsgAwait();
        	session.SendPack(Pack_for_lock(id, isLock));
        	NetProtocolHelper.beginCallRequest?.Invoke(NetMessageId.pet_lockResult);
			return task;
        }
		
		public static SendPackage Pack_for_lock(long id, bool isLock) 
		{
			SendPackage si_p = NetProtocolHelper.GetSendPackage();
			si_p.Header.Messagid = NetMessageId.pet_lock;
			si_p.StartWrite();
			SOutputStream _out = si_p.OutputStream;
			_out.Write_long(id);
			_out.Write_boolean(isLock);
			return si_p;
		}
		/// <summary>
        ///  解锁技能槽
        /// </summary>
    	public UniTask<UnlockSkillSlotResultData> CS_unlockSkillSlot(long id)
        {
            return _CS_unlockSkillSlot(id);
        }
        
        public UniTask<UnlockSkillSlotResultData> _CS_unlockSkillSlot(long id)
        {
        	ISession session = GetSession();
        	if(session == null) return UniTask.FromResult(default(UnlockSkillSlotResultData));
#if ENABLE_NET_LOG || UNITY_EDITOR
			NetProtocolHelper.ClientLog(NetMessageId.pet_unlockSkillSlot, "Send->"+"Pet.CS_unlockSkillSlot { "
				+ "id="
				+ id
				+" }");
#endif
        	UniTask<UnlockSkillSlotResultData> task = MsgAsyncAwaiter<UnlockSkillSlotResultData>.Instance.AddMsgAwait();
        	session.SendPack(Pack_for_unlockSkillSlot(id));
        	NetProtocolHelper.beginCallRequest?.Invoke(NetMessageId.pet_unlockSkillSlotResult);
			return task;
        }
		
		public static SendPackage Pack_for_unlockSkillSlot(long id) 
		{
			SendPackage si_p = NetProtocolHelper.GetSendPackage();
			si_p.Header.Messagid = NetMessageId.pet_unlockSkillSlot;
			si_p.StartWrite();
			SOutputStream _out = si_p.OutputStream;
			_out.Write_long(id);
			return si_p;
		}
		/// <summary>
        ///  使用词条--不同组可能有重复
        /// </summary>
    	public UniTask<PutOnRandAttrResultData> CS_putOnRandAttr(long id, int groupId, int randAttrId)
        {
            return _CS_putOnRandAttr(id, groupId, randAttrId);
        }
        
        public UniTask<PutOnRandAttrResultData> _CS_putOnRandAttr(long id, int groupId, int randAttrId)
        {
        	ISession session = GetSession();
        	if(session == null) return UniTask.FromResult(default(PutOnRandAttrResultData));
#if ENABLE_NET_LOG || UNITY_EDITOR
			NetProtocolHelper.ClientLog(NetMessageId.pet_putOnRandAttr, "Send->"+"Pet.CS_putOnRandAttr { "
				+ "id="
				+ id
				+ ", groupId="
				+ groupId
				+ ", randAttrId="
				+ randAttrId
				+" }");
#endif
        	UniTask<PutOnRandAttrResultData> task = MsgAsyncAwaiter<PutOnRandAttrResultData>.Instance.AddMsgAwait();
        	session.SendPack(Pack_for_putOnRandAttr(id, groupId, randAttrId));
        	NetProtocolHelper.beginCallRequest?.Invoke(NetMessageId.pet_putOnRandAttrResult);
			return task;
        }
		
		public static SendPackage Pack_for_putOnRandAttr(long id, int groupId, int randAttrId) 
		{
			SendPackage si_p = NetProtocolHelper.GetSendPackage();
			si_p.Header.Messagid = NetMessageId.pet_putOnRandAttr;
			si_p.StartWrite();
			SOutputStream _out = si_p.OutputStream;
			_out.Write_long(id);
			_out.Write_int(groupId);
			_out.Write_int(randAttrId);
			return si_p;
		}
		/// <summary>
        ///  取下词条
        /// </summary>
    	public UniTask<PutOffRandAttrResultData> CS_putOffRandAttr(long id, int groupId, int randAttrId)
        {
            return _CS_putOffRandAttr(id, groupId, randAttrId);
        }
        
        public UniTask<PutOffRandAttrResultData> _CS_putOffRandAttr(long id, int groupId, int randAttrId)
        {
        	ISession session = GetSession();
        	if(session == null) return UniTask.FromResult(default(PutOffRandAttrResultData));
#if ENABLE_NET_LOG || UNITY_EDITOR
			NetProtocolHelper.ClientLog(NetMessageId.pet_putOffRandAttr, "Send->"+"Pet.CS_putOffRandAttr { "
				+ "id="
				+ id
				+ ", groupId="
				+ groupId
				+ ", randAttrId="
				+ randAttrId
				+" }");
#endif
        	UniTask<PutOffRandAttrResultData> task = MsgAsyncAwaiter<PutOffRandAttrResultData>.Instance.AddMsgAwait();
        	session.SendPack(Pack_for_putOffRandAttr(id, groupId, randAttrId));
        	NetProtocolHelper.beginCallRequest?.Invoke(NetMessageId.pet_putOffRandAttrResult);
			return task;
        }
		
		public static SendPackage Pack_for_putOffRandAttr(long id, int groupId, int randAttrId) 
		{
			SendPackage si_p = NetProtocolHelper.GetSendPackage();
			si_p.Header.Messagid = NetMessageId.pet_putOffRandAttr;
			si_p.StartWrite();
			SOutputStream _out = si_p.OutputStream;
			_out.Write_long(id);
			_out.Write_int(groupId);
			_out.Write_int(randAttrId);
			return si_p;
		}
#endregion
#region Messages
        public struct FreeResultData : IReceiveMessage {
        	private int? _code;
        	public int code {get{return _code == null ? -1 : (int)_code;}private set{_code = value;}}
            public bool IsFail => _code != null && _code != 0;
            public bool IsSuccess =>_code != null && _code == 0;
            public bool IsCanceled => _code == null;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                code = _in.HasRemaining() ? _in.Read_int() : default;
            }
            
            public int GetMessageId() {return NetMessageId.pet_freeResult;}
            
            public override string ToString()
            {
                return "Pet.freeResult"+ ", code="+ code;
            }
        }
        public struct UpLevelResultData : IReceiveMessage {
        	private int? _code;
        	public int code {get{return _code == null ? -1 : (int)_code;}private set{_code = value;}}
	        public PetPOD petPOD;
            public bool IsFail => _code != null && _code != 0;
            public bool IsSuccess =>_code != null && _code == 0;
            public bool IsCanceled => _code == null;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                code = _in.HasRemaining() ? _in.Read_int() : default;
                petPOD = _in.HasRemaining() ? _in.Read_pod<PetPOD>(PetPOD.DynamicFactory) : default;
            }
            
            public int GetMessageId() {return NetMessageId.pet_upLevelResult;}
            
            public override string ToString()
            {
                return "Pet.upLevelResult"+ ", code="+ code+ ", petPOD="+ petPOD;
            }
        }
        public struct RenameResultData : IReceiveMessage {
        	private int? _code;
        	public int code {get{return _code == null ? -1 : (int)_code;}private set{_code = value;}}
            public bool IsFail => _code != null && _code != 0;
            public bool IsSuccess =>_code != null && _code == 0;
            public bool IsCanceled => _code == null;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                code = _in.HasRemaining() ? _in.Read_int() : default;
            }
            
            public int GetMessageId() {return NetMessageId.pet_renameResult;}
            
            public override string ToString()
            {
                return "Pet.renameResult"+ ", code="+ code;
            }
        }
        public struct LockResultData : IReceiveMessage {
        	private int? _code;
        	public int code {get{return _code == null ? -1 : (int)_code;}private set{_code = value;}}
            public bool IsFail => _code != null && _code != 0;
            public bool IsSuccess =>_code != null && _code == 0;
            public bool IsCanceled => _code == null;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                code = _in.HasRemaining() ? _in.Read_int() : default;
            }
            
            public int GetMessageId() {return NetMessageId.pet_lockResult;}
            
            public override string ToString()
            {
                return "Pet.lockResult"+ ", code="+ code;
            }
        }
        public struct UnlockSkillSlotResultData : IReceiveMessage {
        	private int? _code;
        	public int code {get{return _code == null ? -1 : (int)_code;}private set{_code = value;}}
            public bool IsFail => _code != null && _code != 0;
            public bool IsSuccess =>_code != null && _code == 0;
            public bool IsCanceled => _code == null;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                code = _in.HasRemaining() ? _in.Read_int() : default;
            }
            
            public int GetMessageId() {return NetMessageId.pet_unlockSkillSlotResult;}
            
            public override string ToString()
            {
                return "Pet.unlockSkillSlotResult"+ ", code="+ code;
            }
        }
        public struct PutOnRandAttrResultData : IReceiveMessage {
        	private int? _code;
        	public int code {get{return _code == null ? -1 : (int)_code;}private set{_code = value;}}
	        public PetPOD petPOD;
            public bool IsFail => _code != null && _code != 0;
            public bool IsSuccess =>_code != null && _code == 0;
            public bool IsCanceled => _code == null;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                code = _in.HasRemaining() ? _in.Read_int() : default;
                petPOD = _in.HasRemaining() ? _in.Read_pod<PetPOD>(PetPOD.DynamicFactory) : default;
            }
            
            public int GetMessageId() {return NetMessageId.pet_putOnRandAttrResult;}
            
            public override string ToString()
            {
                return "Pet.putOnRandAttrResult"+ ", code="+ code+ ", petPOD="+ petPOD;
            }
        }
        public struct PutOffRandAttrResultData : IReceiveMessage {
        	private int? _code;
        	public int code {get{return _code == null ? -1 : (int)_code;}private set{_code = value;}}
	        public PetPOD petPOD;
            public bool IsFail => _code != null && _code != 0;
            public bool IsSuccess =>_code != null && _code == 0;
            public bool IsCanceled => _code == null;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                code = _in.HasRemaining() ? _in.Read_int() : default;
                petPOD = _in.HasRemaining() ? _in.Read_pod<PetPOD>(PetPOD.DynamicFactory) : default;
            }
            
            public int GetMessageId() {return NetMessageId.pet_putOffRandAttrResult;}
            
            public override string ToString()
            {
                return "Pet.putOffRandAttrResult"+ ", code="+ code+ ", petPOD="+ petPOD;
            }
        }
        public struct NotifyPetActiveData : IReceiveMessage {
	        public PetPOD petPOD;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                petPOD = _in.HasRemaining() ? _in.Read_pod<PetPOD>(PetPOD.DynamicFactory) : default;
            }
            
            public int GetMessageId() {return NetMessageId.pet_notifyPetActive;}
            
            public override string ToString()
            {
                return "Pet.notifyPetActive"+ ", petPOD="+ petPOD;
            }
        }
        public struct NotifyPetBagCapacityData : IReceiveMessage {
	        public int capacity;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                capacity = _in.HasRemaining() ? _in.Read_int() : default;
            }
            
            public int GetMessageId() {return NetMessageId.pet_notifyPetBagCapacity;}
            
            public override string ToString()
            {
                return "Pet.notifyPetBagCapacity"+ ", capacity="+ capacity;
            }
        }
        public struct NotifyPetRemoveData : IReceiveMessage {
	        public List<long> removeList;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                removeList = _in.HasRemaining() ? _in.Read_list_long() : default;
            }
            
            public int GetMessageId() {return NetMessageId.pet_notifyPetRemove;}
            
            public override string ToString()
            {
                return "Pet.notifyPetRemove"+ ", removeList="+ removeList.ToString<long>();
            }
        }
    }
#endregion
}